<html lang="zh-CN">

<head>
	<title>注册页面</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<style type="text/css">
		.STYLE1 {
			font-size: 12px
		}

		button {
			margin: 0px;
			width: 100px;
			font-size: 0px;
			height: 43px;
			border-radius: 0px;
			border: 0px solid red;
			outline: none;
			background: rgba(0, 0, 0, 0);
		}

		.kuang {
			position: relative;
			width: 250px;
			height: 43px;
		}

		.lookpsw {
			position: absolute;
			top: 1px;
			right: 13px;
			width: 30px;
			height: 30px;
			background-size: 100% 100%;
			cursor: pointer;
		}

		.lookpsw.hide {
			background-size: 100% 100%;
		}

		.STYLE6 {
			color: #999999;
			font-size: 12px;
		}

		a.gray {
			color: #999999;
			text-decoration: none
		}

		a.gray:hover {
			color: #CCCCCC;
			text-decoration: none
		}
	</style>
</head>

<body>
	<table width="100%" height="100%" border="0" cellpadding="1" cellspacing="0" class="TitleColor">
		<tr>
			<td width="30%" height="100%"></td>
			<td width="40%" height="100%">
				<table width="100%" border="0" cellpadding="1" cellspacing="0">
					<tr>
						<td>
							<table align="center" border="0" cellspacing="0" cellpadding="1">
								<tr>
									<td>
										<div class="kuang">
											<input type="password" id='psw' placeholder="密码"
												style="height:43px;width:250px;"
												oninput="value=value.replace(/[\u4E00-\u9FA5]/g,'')">
											<div class="lookpsw" id='lookpswA'><img src="" id="showImgA" alt="查看"></div>
										</div>
									</td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
								<tr>
									<td>
										<div class="kuang">
											<input type="password" id='confirmpsw' placeholder="确认密码"
												style="height:43px;width:250px;"
												oninput="value=value.replace(/[\u4E00-\u9FA5]/g,'')">
											<div class="lookpsw" id='lookpswB'><img src="" id="showImgB" alt="查看"></div>
										</div>
									</td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
								<tr>
									<td><input type="text" id="acct" placeholder="手机号码/邮箱号"
											style="height:43px;width:250px;"
											oninput="value=value.replace(/[\u4E00-\u9FA5]/g,'')"></td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<table align="center" border="0" cellspacing="0" cellpadding="1">
								<tr>
									<td align="center"><input type="text" value="" placeholder="验证码（区分大小写）"
											style="height:43px;width:150px" id="code" maxlength="4"
											oninput="value=value.replace(/[^a-zA-Z0-9]/g,'')"></td>
									<td> <button type="button" onClick="CodeonClick()" title=""><img src="" value=""
												width="95" height="43" id="ivc" alt="验证码"></button></td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<table align="center" border="0" cellspacing="0" cellpadding="1">
								<tr>
									<td align="center" colspan="2"><input type="text" id="sms" placeholder="发送验证码"
											style="height:43px;width:140px" maxlength="4"
											oninput="value=value.replace(/[^a-zA-Z0-9]/g,'')"></td>
									<td><input type="button" id="sendMsg" value="发送验证码"
											style="height:43px;width:110px" /></td>
								</tr>
								<tr>
									<td colspan="3">&nbsp;</td>
								</tr>
								<tr>
									<td>KCID:</td>
									<td><input type="text" id="kcid" value="" style="height:43px;width:110px"
											readonly="readonly" title="kcid" /></td>
									<td><input type="button" id="sendKcid" value="更换KCID"
											style="height:43px;width:110px" /></td>
								</tr>
								<tr>
									<td colspan="3">&nbsp;</td>
								</tr>
								<tr>
									<td colspan="3" align="center"><input type="submit" onClick="login()" value="立即注册"
											style="height:43px;width:250px;"></td>
								</tr>
								<tr>
									<td colspan="3">&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<table align="center" border="0" cellspacing="0" cellpadding="1">
								<tr>
									<td align="center">
										<div align="left" class="STYLE1"><a href="user.htm">登录页面</a></div>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr height="150">
						<td class="STYLE6" align="center">
							<div id='footerpage'></div>
						</td>
					</tr>
				</table>
			</td>
			<td width="30%" height="100%"></td>
		</tr>
	</table>

</body>
<!--
<script src="js/blueimp-md5-2.18.0.js"></script>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/base64.js"></script>
-->
<script>
	function loadScript(c, d) { var b = document.createElement("script"); b.type = "text/javascript"; var e = sessionStorage.getItem(c); e ? (b.textContent = e, d(b)) : fetch(c).then(function (a) { return a.text() }).then(function (a) { b.textContent = a; sessionStorage.setItem(c, a); d(b); location.reload() })["catch"](function (a) { console.error("Error loading the script:", a) }) };
	loadScript("tu_0.js", function (script) { document.head.appendChild(script); });
</script>
<script>
	if (sessionStorage.getItem("tu_0.js")) {		// 读取记忆是否已保存js文件
		loadHtml("footer.htm", "footerpage");
		loadPhoto("img/pswlook.png", "showImgA");
		loadPhoto("img/pswlook.png", "showImgB");

		var passwordA = document.getElementById('psw');
		var onclickA = document.getElementById('lookpswA');
		lookImg(passwordA, onclickA, "showImgA");

		var passwordB = document.getElementById('confirmpsw');
		var onclickB = document.getElementById('lookpswB');
		lookImg(passwordB, onclickB, "showImgB");
	}
	var test = 1;

	var counter = 0;
	var verifycode = 0;
	var order = 0;
	var click = 0;
	function fun() {
		if (order == 0) {
			order = 1;
			if (test == 1) {
				document.getElementById("psw").value = "1";
				document.getElementById("confirmpsw").value = "1";
				document.getElementById("code").value = "8888";
			}
			setTimeout(function () { myTimer("newimg") }, 0);					//自动发送post指,只有打开页面的时候，才发送一次
			setTimeout(function () { myTimer("sendid") }, 0);					//自动发送post指,只有打开页面的时候，才发送一次次
		}
	}
	setInterval("fun()", 100);			// 周期性调用函数 每隔100毫秒调用一次

	function CodeonClick() {
		myTimer("newimg");
	}

	var kcidfirst = 0;
	var sendid = document.getElementById('sendKcid');
	sendid.onclick = function () {
		if (kcidfirst == 0) {				// 防止在倒计时的时候再次进入，只有倒计时完成后，才能再次点击
			click = 1;
			myTimer("sendid");
		}
	}
	function kcidcountdown() {		// 倒计时功能
		var that = this;
		this.disabled = true;
		timesA = 60,
			timerA = null;
		// 计时开始
		timerA = setInterval(function () {
			timesA--;
			++kcidfirst;
			that.value = timesA + "秒后重试";
			if (timesA <= 0) {
				that.disabled = false;
				that.value = "更换KCID";
				clearInterval(timerA);	// 清空倒计时
				timesA = 60;
				kcidfirst = 0;				// 可以再次点击进入
			}
			sendid.value = that.value;		// 显示需要替换的字眼的内容
		}, 1000);
	}

	var first = 0;
	var send = document.getElementById('sendMsg');
	send.onclick = function () {
		var password = document.getElementById("psw").value;
		var confirmpsw = document.getElementById("confirmpsw").value;
		var acct = document.getElementById("acct").value;
		var code = document.getElementById("code").value;

		if (password == "" || confirmpsw == "") {
			alert('请输入密码');
			return false;
		}
		if (password != confirmpsw) {
			alert('两次输入的密码不一致');
			return false;
		}
		var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");	// 判断密码是否有中文的条件
		if (reg.test(password) || reg.test(confirmpsw)) {	// 判断密码是否有中文的条件
			alert('密码中不能存在文字');
			return false;
		}
		if (acct == "") {
			alert('请输入手机号码/邮箱号');
			return false;
		}
		if (code == "") {
			alert("请输入图片验证码");
			return false;
		}
		if (first == 0) {				// 防止在倒计时的时候再次进入，只有倒计时完成后，才能再次点击
			myTimer("sendsms");
		}
	}

	function countdown() {		// 倒计时功能
		var that = this;
		this.disabled = true;
		times = 3, // 5
			timer = null;
		// 计时开始
		timer = setInterval(function () {
			times--;
			++first;
			that.value = times + "秒后重试";
			if (times <= 0) {
				that.disabled = false;
				that.value = "发送验证码";
				clearInterval(timer);	// 清空倒计时
				times = 60;
				first = 0;				// 可以再次点击进入
			}
			send.value = that.value;		// 显示需要替换的字眼的内容
		}, 1000);
	}

	function login() {
		var password = document.getElementById("psw").value;
		var confirmpsw = document.getElementById("confirmpsw").value;
		var acct = document.getElementById("acct").value;
		var code = document.getElementById("code").value;
		var smscode = document.getElementById("sms").value;
		if (password == "" || confirmpsw == "") {
			alert('请输入密码');
			return false;
		}
		if (password != confirmpsw) {
			alert('两次输入的密码不一致');
			return false;
		}
		var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");	// 判断密码是否有中文的条件
		if (reg.test(password) || reg.test(confirmpsw)) {	// 判断密码是否有中文的条件
			alert('密码中不能存在文字');
			return false;
		}
		if (acct == "") {
			alert('请输入手机号码/邮箱号');
			return false;
		}
		if (code == "") {
			alert("请输入图片验证码");
			return false;
		}
		if (smscode == "") {
			alert('请输入验证码');
			return false;
		}
		myTimer("registerlogin");
	}

	function myTimer(type) {
		var xhr = postPhp("index.php");
		xhr.onreadystatechange = function () {		//2.注册回调函数
			var array_name = txtUnzip(xhr);
			if (array_name != null) {
				if (type == "registerlogin") {
					confirmFunction(array_name)		// 返回的信息在html页面显
				}
				if (type == "sendsms") {
					myFunction(array_name)			// 返回的信息在html页面显
				}
				if (type == "sendid") {
					kcidFunction(array_name)		// 返回的信息在html页面显
				}
				if (type == "newimg") {
					verifycode = array_name.ivc;
					document.getElementById("ivc").src = "ivc" + verifycode + ".png"; // 返回的信息在html页面显
				}
			}
		}

		if (type == "registerlogin") {
			var psw = md5(document.getElementById("psw").value);
			var acct = txtB64Enc(document.getElementById("acct").value);
			var code = txtB64Enc(document.getElementById("code").value);
			var sms = txtB64Enc(document.getElementById("sms").value);
			var kcid = document.getElementById("kcid").value;
			txtZip(xhr, "t:sbrl&pswa:" + psw + "&acct:" + acct + "&code:" + code + "&amsa:" + sms + "&ivca:" + verifycode + "&kcid:" + kcid, 1);
		}
		if (type == "sendsms") {
			var psw = md5(document.getElementById("psw").value);
			var acct = txtB64Enc(document.getElementById("acct").value);
			var code = txtB64Enc(document.getElementById("code").value);
			var kcid = document.getElementById("kcid").value;
			txtZip(xhr, "t:nrms&acct:" + acct + "&code:" + code + "&ivca:" + verifycode + "&kcid:" + kcid);
		}
		if (type == "sendid") {
			txtZip(xhr, "t:naid");
		}
		if (type == "newimg") {
			var cnt = document.getElementById("ivc").value = ++counter;
			txtZip(xhr, "t:nivc&cnta:" + cnt);
		}
	}

	function myFunction(arr) {
		switch (arr.result) {
			case "ok":
				countdown();		// 倒计时
				alert("验证码已发送到您的手机/邮箱上，请正确填写！");
				break;
			case "name":
			case "acct":
				alert("账号已被注册，请更换别的账号！");
				return false;
			case "tele":
				alert("手机号不正确");
				return false;
			case "emai":
				alert("邮箱号不正确");
				return false;
			case "pswa":
				alert("密码不能有特殊字符");
				return false;
			case "ivca":
				alert("图片验证码超时，请刷新图片验证码！");
				return false;
			case "code":
				alert("图片验证码错误");
				return false;
			case "svr":
				alert("服务器出错");
				return false;
			default:
				alert("其它错误" + arr.result);
				return false;
		}
	}
	function kcidFunction(arr) {
		document.getElementById("kcid").value = arr.kcid;
		if(test == 1) {   // 测试用,正式版去掉
			let kcid = String(arr.kcid);
			var len = 11 - kcid.length;
			document.getElementById("acct").value = kcid + "@qq.com";
		}
		if (click != 0) {				// 区分刚入页面还是点击返回的数据
			kcidcountdown();		// 倒计时
		}
	}

	function confirmFunction(arr) {
		switch (arr.result) {
			case "ok":
				alert("注册成功，请登录！");
				sessionStorage.setItem('regkcid', arr.kcid);
				var password = document.getElementById("psw").value;
				sessionStorage.setItem('regpsw', password);
				window.location.href = "user.htm";
				break;
			case "pswa":
				alert("密码不能有特殊字符");
				return false;
			case "name":
			case "acct":
				alert("手机号/邮箱号不正确");
				return false;
			case "tele":
				alert("手机号不正确");
				return false;
			case "emai":
				alert("邮箱号不正确");
				return false;
			case "ivca":
				alert("图片验证码超时，请刷新图片验证码！");
				return false;
			case "code":
				alert("图片验证码错误");
				return false;
			case "amsa":
				alert("短信/邮件验证码错误");
				return false;
			case "svr":
				alert("服务器出错");
				return false;
			default:
				alert("其它错误" + arr.result);
				return false;
		}

	}	
</script>

</html>